package com.tanhua.model.vo;

import com.tanhua.model.db.UserInfo;
import com.tanhua.model.mongo.Movement;
import com.tanhua.model.mongo.Voice;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.util.StringUtils;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author solang
 * @date 2021-12-22 20:09
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class VoiceVo implements Serializable {
    private Integer id;//用户id
    private String avatar;//头像
    private String nickname;//昵称
    private String gender;//性别
    private Integer age;//年龄
    private String soundUrl;//语音地址
    private Integer remainingTimes;//剩余语音接收次数

    //将语音信息和用户信息封装成Vo
    public static VoiceVo init(UserInfo userInfo, Voice voice) {
        //定义VoiceVo对象接收数据
        VoiceVo voiceVo = new VoiceVo();
        //设置语音数据
        BeanUtils.copyProperties(voice,voiceVo);
        //设置用户数据
        BeanUtils.copyProperties(userInfo,voiceVo);
        //设置用户id
        voiceVo.setId(voice.getUserId().intValue());
        return voiceVo;
    }
}
